﻿using System;

class DigitReverse
{
    static void Main()
    {
        Console.Write("Enter a number: ");
        decimal deciNumReversed = ReverseDigits(decimal.Parse(Console.ReadLine()));
        Console.WriteLine("Reversed: " + deciNumReversed);
    }

    static decimal ReverseDigits(decimal number)
    {
        string decimalStr = number.ToString();
        string reversed = "";
        int length = decimalStr.Length;

        // If the length is an odd number first we take the digit in the middle 
        if (length % 2 != 0)
        {
            reversed = char.ToString(decimalStr[length / 2]);
        }

        for (int i = (length / 2) - 1; i >= 0; i--)
        {
            reversed = char.ToString(decimalStr[length - 1 - i]) + reversed + char.ToString(decimalStr[i]);
        }

        return Convert.ToDecimal(reversed);
    }
}
